import Databus from '../databus'
const databus = new Databus()

export default class Pad {
    constructor(){
        this.image = databus.imgObj.score_panel
        // 位置
        this.x = (databus.canvas.width-this.image.width) / 2
        this.y = databus.canvas.height
        // 宽高
        this.w = this.image.width
        this.h = this.image.height
        this.ey = 220
        databus.addActor(this)
    }
    update(){
        this.y -= 40
        if (this.y <= this.ey){
            this.y = this.ey
            this.end = true
        }
    }
    render(){
        databus.ctx.drawImage(this.image, this.x, this.y, this.w, this.h)
        if (this.end){
            databus.ctx.save()
            databus.ctx.fillStyle = "#00f"
            databus.ctx.font = "20px Arial"
            databus.ctx.fillText(databus.score, databus.canvas.width / 2 + 70, 270)
            databus.ctx.fillText(databus.max, databus.canvas.width / 2 + 70, 315)
            databus.ctx.restore()
        }
    }
}